﻿using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Sharp.Domain.Model;
using Sharp.Domain.PlatformBoundedContext.WorkFlowModule.Engine.Common;
using Sharp.Infrastructure;

namespace Sharp.Domain.PlatformBoundedContext.WorkFlowModule.Aggregates
{
    /// <summary>
    /// 任务实体对象
    /// </summary>
    [Table("WorkFlow_Tasks")]
    public class TaskEntity : IAggregateRoot<int>, ILogCreatedExEntity, ILogModifiEntity
    {
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [Column(Order = 0)]
        public int Id { get; set; }

        [Required]
        [Column(Order = 1)]
        public int ActivityInstanceID { get; set; }

        [Required]
        [Column(Order = 2)]
        public int ProcessInstanceID { get; set; }

        [Required]
        [Column( Order = 3)]
        [MaxLength(50)]
        public string AppName { get; set; }

        [Required]
        [Column(  Order = 4)]
        [MaxLength(50), NonUnicode]
        public string AppInstanceID { get; set; }

        [Required]
        [Column(  Order = 5)]
        [MaxLength(100), NonUnicode]
        public string ProcessGUID { get; set; }

        [Required]
        [Column(  Order = 6)]
        [MaxLength(100), NonUnicode]
        public string ActivityGUID { get; set; }

        [Required]
        [Column(  Order = 7)]
        [MaxLength(50), NonUnicode]
        public string ActivityName { get; set; }

        [Required]
        [Column(Order = 8)]
        public TaskTypeEnum TaskType { get; set; }

        [Required]
        [Column(Order = 9)]
        public TaskStateEnum TaskState { get; set; }

        [Column(Order = 10)]
        public int? EntrustedTaskID { get; set; }        //被委托任务ID

        [Required]
        [Column(  Order = 11)]
        [MaxLength(50), NonUnicode]
        public string AssignedToUserID { get; set; }

        [Required]
        [Column( Order = 12)]
        [MaxLength(50)]
        public string AssignedToUserName { get; set; }

        [Required]
        [Column(  Order = 13)]
        public int? CreatedUserId { get; set; }

        [Required]
        [Column( Order = 14)]
        [MaxLength(50)]
        public string CreatedUserName { get; set; }

        [Required]
        [Column( Order = 15)]
        public System.DateTime? CreatedTime { get; set; }

        [Column( Order = 16)]
        public DateTime? ModifiTime { get; set; }

        [Column(  Order = 17)]
        public int? ModifiedUserId { get; set; }

        [Column( Order = 18)]
        [MaxLength(50)]
        public string LastUpdatedByUserName { get; set; }

        [Column( Order = 19)]
        [MaxLength(50), NonUnicode]
        public string EndedByUserID { get; set; }

        [Column(  Order = 20)]
        [MaxLength(50), NonUnicode]
        public string EndedByUserName { get; set; }

        [Column( Order = 21)]
        public DateTime? EndedDateTime { get; set; }

        [Required]
        [Column(Order = 22)]
        public byte RecordStatusInvalid { get; set; }

        [Timestamp]
        [Column( Order = 23)]
        public byte[] RowVersionID { get; set; }

        public virtual ActivityInstanceEntity ActivityInstance{ get; set; }
        public virtual ProcessInstanceEntity ProcessInstance  { get; set; }
    }
}
